package com.gxa.xx;

import com.gxa.xx.dao.LocationDao;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;

@Component
public class Setup {

    private LocationDao locationDao;
//    private RedisTemplate<String, Object> template;

//    public Setup(LocationDao locationDao, RedisTemplate<String, Object> template) {
//        this.locationDao = locationDao;
//        this.template = template;
//    }


    public Setup(LocationDao locationDao) {
        this.locationDao = locationDao;
    }

    @PostConstruct
    public void loadDataToRedis() {
        String province = "province";
        String city = "city";
        String block = "block";

//        if (!template.hasKey(province)) {
//            locationDao.getProvinces()
//                    .forEach(entry -> {
//                        template.opsForHash().put(province, entry.get("id"), entry.get("name"));
//                    });
//        }
    }
}
